package net.chathu.airgw.packets.chat 
{
	import net.chathu.airgw.Debug;
	import net.chathu.airgw.model.PrivateChatInfo;
	import net.chathu.airgw.model.User;
	import net.chathu.airgw.packets.gw.serverpackets.NoticePacket;
	/**
	 * ...
	 * @author ze
	 */
	public class IRemPrivate extends ChatPacket
	{
		
		public function IRemPrivate() 
		{
			
		}
		
		override public function execute():void
		{
			var closeId:int = parseInt(data[2]);
			
			var privInfo:PrivateChatInfo = sessionData.chatData.getPrivateChatInfoByCloseId(closeId);
			
			if (privInfo)
			{
				var partner:User = User(sessionData.chatData.users.getUser(privInfo.partnerId));
				//ha sajat magaddal beszeltel, ne jelezze a veget..
				if (partner.id != sessionData.chatData.userId)
				{
					sendToClient(new NoticePacket(partner.userHost, sessionData.nick, "A beszélgetés befejeződött!"));
				}
				sessionData.chatData.removePrivateChatInfo(privInfo.privateId);
				Debug.echo("IREMP->Privates: " + sessionData.chatData.privateChats.length);
			} else {
				trace("IRemPrivate error, closeId: " + closeId);
			}
		}
	}

}